<template>
	<view class="page">
		<!-- 总公司首页-->
		<zong-gong-si v-show="showIndex == 'zongGongSi'" ref="zongGongSi" />
		<!-- 用户首页 -->
		<yong-hu v-show="showIndex == 'yongHu'" ref="yonghu" />
		<!-- 银行端首页 -->
		<yin-hang-duan v-show="showIndex == 'yinHangDuan'" ref="yinHangDuan" />
		<!-- 经销商首页 -->
		<jing-xiao-shang v-show="showIndex == 'jingXiaoShang'" ref="jingXiaoShang" />
		<!-- 销售首页 -->
		<xiao-shou v-show="showIndex == 'xiaoShou'" ref="xiaoShou" />
		<!-- 大区首页 -->
		<da-qu-shou-ye v-show="showIndex == 'daQuShouYe'" ref="daQuShouYe" />
		
	</view>
</template>

<script>
	import yongHu from "../components/yong_hu_shou_ye"; 
	import zongGongSi from "../components/zong_gong_si_shou_ye";
	import yinHangDuan from "../components/yin_hang_duan_shou_ye";
	import jingXiaoShang from "../components/jing_xiao_shang_shou_ye";
	import xiaoShou from "../components/xiao_shou_duan_shou_ye";
	import daQuShouYe from "../components/da_qu_shou_ye";
	import {
		getCode
	} from '@/utils/weixin.util.js'
	export default {
		components: {
			zongGongSi,
			yongHu,
			yinHangDuan,
			jingXiaoShang,
			xiaoShou,
			daQuShouYe,
		},
		data() {
			return {
				showIndex: 'yongHu' //次变量控制要显示那个首页，默认显示用户首页,后台传回的变量
			}
		},
		onShow() {
			var role = uni.getStorageSync('roles')
			var orgCategory = uni.getStorageSync('orgCategory')
			console.log(orgCategory,'orgCategory');
			console.log(role,'role');
			if (role) {
				this.shouIndex(role,orgCategory)
			}
			if (uni.getStorageSync('account')) {
				this.$refs.yonghu.isRegister = true
			}
		},
		methods: {
			// 根据后台返回的参数展示那个首页,调此方法,并传参数进去
			shouIndex(val,orgCategory) {
				if (!val) {
					return
				}
				// if (val == "customer") {
				// 	this.showIndex = "yongHu"
				// 	this.$refs.yonghu.load()
				// 	return
				// }
				if (val.includes("销售")) {
					this.showIndex = "xiaoShou"
					this.$refs.xiaoShou.load()
					return
				}
				if (val.includes("银行客户经理")) {
					this.showIndex = "yinHangDuan"
					this.$refs.yinHangDuan.load()
					return
				}
				// 总公司的
				if (val.includes("管理员") && orgCategory == 'DEPT') {
					this.showIndex = "daQuShouYe"
					console.log('大区端的');
					this.$refs.daQuShouYe.load()
					return
				} 
				// 大区端的
				if (val.includes("管理员") && orgCategory == 'COMPANY') {
					this.showIndex = "zongGongSi"
					console.log('总公司的');
					this.$refs.zongGongSi.load()
					return
				} 

				
				if (val.includes("经销商")) {
					this.showIndex = "jingXiaoShang"
					this.$refs.jingXiaoShang.load()
					return
				}
			},
		}
	}
</script>

<style>
	.page {
		overflow-y: auto;
		width: 100%;
		height: 100vh;
		background-color: #fff;
	}
</style>